package com.example.canteen.controller;

import com.example.canteen.Response;
import com.example.canteen.dao.SetMeal;
import com.example.canteen.dto.SetMealDTO;
import com.example.canteen.service.SetMealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@RestController
@RequestMapping("/setMeal")
public class SetMealController {
    @Autowired
    SetMealService setMealService;

    @PostMapping("/all")
    public Response<Set<SetMealDTO>> getAllSetMeals() {
        return Response.newSuccess(setMealService.getAllSetMeals());
    }
    @PostMapping("/add")
    public Response<Long> addSetMeal(@RequestBody SetMealDTO setMealDTO) {
        return Response.newSuccess(setMealService.addSetMeal(setMealDTO,setMealDTO.getCategoryName()));
    }
    @PostMapping("/update")
    public Response<SetMealDTO> updateSetMeal(@RequestBody SetMealDTO setMealDTO) {
        return Response.newSuccess(setMealService.updateSetMeal(setMealDTO));
    }
}
